{block name=body}
<div class="row">
	<div class="col-sm-12">
		<form class="well form-horizontal" id="Edit_Record" accept-charset="UTF-8" method="post" autocomplete=off>
			<div class="row">
				<div class="col-sm-12 edit-page-header">
					<span class="edit-page-title">{if $fields.holiday_id neq ""}编辑{else}新建{/if} 假期 {if $cnt eq ""}{assign var=cnt value=0}{/if}</span> 
					<a href="javascript:void(0);" onClick="$('#Edit_Record').submit();" class="btn btn-primary pull-right" style="margin-left: 38px;"><span class="glyphicon glyphicon-floppy-saved"></span> 保存</a>
					<input type="hidden" value="holiday_id" name="primary_id" id="primary_id"/> 
					<input type="hidden" value="{$fields.holiday_id}" name="field[1][tbl_holiday][{$cnt}][holiday_id]" id="holiday_id" /> 
					<input type="hidden" value="holiday_id" name="field[1][tbl_holiday][{$cnt}][id]" id="id" /> 
					<input type="hidden" name="formToken" id="formToken" value="{$token}" />
					
					<input type="hidden" id="error" name="error" value="0" />
				</div>
			</div>
			<ul class="nav nav-tabs" id="myTab">
				<li class="active"><a href="#details" data-toggle="tab">详情</a></li>
				<li><a href="#log" data-toggle="tab">日志</a></li>
			</ul>
			<div class="tab-content">
				<!--===+++===+++===+++===+++===+++ DETAILS TAB +++===+++===+++===+++===+++====-->
				<div class="tab-pane active" id="details">
					<div class="row form" data-error="<b>详情</b>选项上发现错误。打开<b>详情</b>选项以查看特定错误通知。">
						
						<div class="row form-group">
							<label class="col-sm-3 control-label" for="holiday_name">名称 *</label>
							<div class="col-sm-5">
								<input class="form-control" type="text" value="{$fields.holiday_name}" name="field[1][tbl_holiday][{$cnt}][holiday_name]" id="holiday_name" required>
								<span class="help-block"></span>
							</div>
						</div>
						<div class="row form-group">
							<label class="col-sm-3 control-label" for="id_holiday_date">时间 *</label>
							<div class="col-sm-5">
								<input class="form-control dates" type="text" value="{if $fields.holiday_date}{$fields.holiday_date}{else}{$smarty.now|date_format:"%Y-%m-%d"}{/if}"  name="from" id="from" onchange="setDateValue('id_holiday_date',this.value);" required>
								<input type="hidden" value="{if $fields.holiday_date}{$fields.holiday_date}{else}{$smarty.now|date_format:"%Y-%m-%d"}{/if}" name="field[1][tbl_holiday][{$cnt}][holiday_date]" id="id_holiday_date">
							</div>
						</div>
						<div class="row form-group">
							<label class="col-sm-3 control-label" for="id_holiday_state">地区</label>
							<div class="col-sm-3">
								<select class="form-control" name="field[1][tbl_holiday][{$cnt}][holiday_state]" id="id_holiday_state">
									<option value="">所有地区</option>
									<option value="北京" {if $fields.holiday_state eq '北京'}selected="selected"{/if} >北京</option>
									<option value="天津" {if $fields.holiday_state eq '天津'}selected="selected"{/if}>天津</option>
								</select>
							</div>
						</div>
					</div>
				</div>
				<!--===+++===+++===+++===+++===+++ LOG TAB +++===+++===+++===+++===+++====-->
				<div class="tab-pane" id="log">
					<div class="row form" id="tags-wrapper">
						<div class="col-sm-12">
							{if $fields.logs}
								<table class="table table-bordered table-striped table-hover">
									<thead>
										<tr>
											<th>时间</td>
											<th>操作</td>
											<th>用户</td>
										</tr>
									</thead>
									<tbody>
									{foreach $fields.logs as $log}
										<tr>
											<td>{$log.log_created|date_format:"%d/%b/%Y %r"}</td>
											<td>{$log.log_action}</td>
											<td>{$log.admin_name}</td>
										</tr>
									{/foreach}
									</tbody>
								</table>
							{else}
								暂无日志。
							{/if}
						</div>
					</div>
				</div>
			</div>
			<div class="row form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<a href="javascript:void(0);" onClick="$('#Edit_Record').submit();" class="btn btn-primary pull-right" style="margin-top: 50px;"><span class="glyphicon glyphicon-floppy-saved"></span> 保存</a>
				</div>
			</div>
		</form>
	</div>
</div>

{include file='jquery-validation.tpl'}

<script type="text/javascript">

$(document).ready(function(){

	$('#Edit_Record').validate({
		onkeyup: false
	});

	$("#from").datepicker({
		changeMonth : true,
		changeYear : true,
		onSelect : function(selectedDate) {
			$("#id_holiday_date").val( selectedDate );
		}
	});
	
});




</script>

{/block}
